package com.sl.biz.modular.debug.controller;

import com.sl.biz.modular.debug.service.DebuggerBizService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 调试接口
 *
 * @author rongdi
 * @date 2021/1/31
 */
@RestController
@RequestMapping("/process/debugger")
@RequiredArgsConstructor
public class DebuggerController {

    private final DebuggerBizService debuggerBizService;

//    @RequestMapping("/breakpoint")
//    public void breakpoint(@RequestParam String tag, @RequestParam String hostname, @RequestParam Integer port, @RequestParam String className, @RequestParam Integer lineNumber) throws Exception {
////        Debugger debugger = Debugger.getInstance(tag,hostname,port);
////        return debugger.markBpAndGetInfo(className,lineNumber);
//    }
//
//    @RequestMapping("/stepInto")
//    public void stepInto(@RequestParam String tag) throws Exception {
////        Debugger debugger = Debugger.getInstance(tag);
////        return debugger.stepAndGetInfo(EventType.STEP_INTO);
//    }
//
//    @RequestMapping("/stepOver")
//    public void stepOver(@RequestParam String tag) throws Exception {
////        Debugger debugger = Debugger.getInstance(tag);
////        return debugger.stepAndGetInfo(EventType.STEP_OVER);
//    }
//
//    @RequestMapping("/stepOut")
//    public void step(@RequestParam String tag) throws Exception {
////        Debugger debugger = Debugger.getInstance(tag);
////        return debugger.stepAndGetInfo(EventType.STEP_OUT);
//    }

    @PostMapping("/connect")
    public String connect() {
        //先看服务是不是已经启动了,启动成功了， 会写一个文件，失败了，会删除这个文件，那么就通过文件区分
        //如果没有启动，把数据找出来，解压到文件，然后通过命令启动

        //先找文件
        String connect = debuggerBizService.connect();
        return connect;
    }

    @PostMapping("/disconnect")
    public void disconnect() throws Exception {
        //停止服务
        debuggerBizService.disconnect();

    }
}